package org.marsdonne.common.test;

import io.zonky.test.db.postgres.embedded.EmbeddedPostgres;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Consumer;

@Configuration
public class EmbeddedPostgresConfiguration {

    @Value("${test.database.pgSqlVer:12.6}")
    private String pgSqlVer;
    @Value("${test.database.pgGisVer:3.1.4}")
    private String pgGisVer;

    @Bean
    public Consumer<EmbeddedPostgres.Builder> embeddedPostgresCustomizer() {
        return builder -> builder.setPgBinaryResolver(new PostgisBinaryResolver(pgSqlVer, pgGisVer));
    }
}
